'use strict';
const ulid = require('./ulid');
function getMenus(){
  const systemId = ulid.ulid();// 系统
  const configId = ulid.ulid();// 系统 -> config
  const authorizedId = ulid.ulid();// 系统 -> Authorized
  const accountId = ulid.ulid();// 系统 -> Account
  const roleId = ulid.ulid();// 系统 -> Role
  const menuId = ulid.ulid();// 系统 -> Menu
  const planId = ulid.ulid();// 系统 -> Plan
  const speedTemplateId = ulid.ulid();// 系统 -> SpeedTemplate
  const oltTypeId = ulid.ulid();// 系统 -> oltType
  const operationLogId = ulid.ulid();// 系统 ->Operation Log
  const UserId = ulid.ulid();// 系统 ->User
  const OltTypeScriptListId = ulid.ulid();// 系统 ->OltTypeScriptList
  const OltTypeScriptDetailId = ulid.ulid();// 系统 ->OltTypeScriptList
  const SNListId = ulid.ulid();// 系统 ->OltTypeScriptList
  const ModifyPassId = ulid.ulid();// 系统 ->OltTypeScriptList
  const SystemInfoId = ulid.ulid();// 系统 ->SystemInfo
  const oltId = ulid.ulid();// olt
  const oltlistId = ulid.ulid();// olt -> oltlist
  const addoltId = ulid.ulid();// oltlist -> addolt
  const viewId = ulid.ulid();// oltlist -> view
  const initId = ulid.ulid();// oltlist -> init
  const deleteId = ulid.ulid();// oltlist -> delete
  const refreshId = ulid.ulid();// oltlist -> refresh
  const saveId = ulid.ulid();// oltlist -> save
  const oltDetailId = ulid.ulid();// olt -> oltDeatil
  const onuId = ulid.ulid();// onu
  const onulistId = ulid.ulid();// onu -> onulist
  const onulistqueryId = ulid.ulid();// onulist -> query
  const onulistrefreshId = ulid.ulid();// onulist -> refresh
  const onulistdeleteonuId = ulid.ulid();// onulist -> delete onu
  const onulistbinduserId = ulid.ulid();// onulist -> bind user
  const onufindId = ulid.ulid();// onu -> onufind
  const onufindqueryId = ulid.ulid();// onufind -> query
  const onufindrefreshId = ulid.ulid();// onufind -> refresh
  const onufindregistonuId = ulid.ulid();// onufind -> regist onu
  const tr069Id = ulid.ulid();// tr069
  const searctId = ulid.ulid();// tr069 -> search
  const clearId = ulid.ulid();// tr069 -> clear
  const autoRefreshId = ulid.ulid();// tr069 -> auth refresh
  const createGroupId = ulid.ulid();// tr069 -> create group
  const deleteGroupId = ulid.ulid();// tr069 -> delete group
  const moveInGroupId = ulid.ulid();// tr069 -> move in group
  const moveOutGroupId = ulid.ulid();// tr069 -> move out group
  const sendTemplateId = ulid.ulid();// tr069 -> send template
  const advancedId = ulid.ulid();// tr069 -> advanced
  const rebootId = ulid.ulid();// tr069 -> reboot
  const deleteONUId = ulid.ulid();// tr069 -> reboot
  const refreshONUId = ulid.ulid();//tr069 -> refresh
  const setRoleId = ulid.ulid();//tr069 -> refresh
  const delRoleId = ulid.ulid();//tr069 -> refresh
  const user = ulid.ulid()
  const userManagement = ulid.ulid()
  const onuListomci = ulid.ulid()
  const oltProfile = ulid.ulid()
  // type 1:模块 2:按钮 0: 页面
  const result = [
    // 总菜单
    { id: systemId, name: 'SYSTEM',parentName:'', module_id: '0', type: 1, sort: 1, url: '/system', description: 'SYSTEM' },
    { id: oltId, name: 'OLT', parentName:'', module_id: '0', type: 1, sort: 2, url: '/oltlist', description: 'OLT' },
    { id: onuId, name: 'ONU', parentName:'', module_id: '0', type: 1, sort: 3, url: '/ONU', description: 'ONU' },
    {id:user,name:'UserModel',parentName:'',module_id:'0',type:1,sort:4,url:'/UserModel',description:'User'},
    // system 菜单
    { id: configId, name: 'config',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 1, url: '/Config', description: 'config' },
    { id: authorizedId, name: 'Authorized',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 2, url: '/Authorized', description: 'Authorized' },
    { id: accountId, name: 'Account',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 3, url: '/Account', description: 'Account' },
    { id: roleId, name: 'Role',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 4, url: '/Role', description: 'Role' },
    { id: menuId, name: 'Menu',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 5, url: '/Menu', description: 'Menu' },
    { id: planId, name: 'Plan',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 6, url: '/Plan', description: 'Plan' },
    { id: speedTemplateId, name: 'SpeedTemplate',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 7, url: '/SpeedTemplate', description: 'SpeedTemplate' },
    { id: oltTypeId, name: 'OltType',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 8, url: '/OltType', description: 'olt type' },
    { id: operationLogId, name: 'Operation Log',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 9, url: '/operationlog', description: 'Operation Log' },
    { id: UserId, name: 'User',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 10, url: '/User', description: 'User' },
    { id: OltTypeScriptListId, name: 'OltTypeScriptList',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 11, url: '/OltTypeScriptList', description: 'OltTypeScriptList' },
    { id: OltTypeScriptDetailId, name: 'OltTypeScriptDetail',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 12, url: '/OltTypeScriptDetail', description: 'OltTypeScriptDetail' },
    { id: SNListId, name: 'SNList',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 13, url: '/SNList', description: 'SNList' },
    { id: SystemInfoId, name: 'SystemInfo',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 14, url: '/System', description: 'SystemInfo' },
    { id: ModifyPassId, name: 'ModifyPassword',parentName:'SYSTEM', module_id: systemId, type: 0, sort: 15, url: '/modifyPassword', description: 'modify password' },
    // olt 菜单
    { id: oltlistId, name: 'Oltlist',parentName:'OLT', module_id: oltId, type: 0, sort: 1, url: '/Oltlist', description: 'Oltlist' },
    { id: oltDetailId, name: 'OltDetail',parentName:'OLT', module_id: oltId, type: 0, sort: 2, url: '/OltDetail', description: 'OltDetail' },
        { id: oltProfile, name: 'oltProfile',parentName:'OLT', module_id: oltId, type: 0, sort: 3, url: '/oltProfile', description: 'oltProfile' },
    // onu菜单
    { id: onulistId, name: 'Onulist',parentName:'ONU', module_id: onuId, type: 0, sort: 1, url: '/Onulist', description: 'Onulist' },
    { id: onufindId, name: 'Onufind',parentName:'ONU', module_id: onuId, type: 0, sort: 2, url: '/Onufind', description: 'Onufind' },
    { id: tr069Id, name: 'tr069',parentName:'ONU', module_id: onuId, type: 0, sort: 3, url: '/tr069', description: 'tr069' },
    { id: onuListomci, name: 'onuListomci',parentName:'ONU', module_id: onuId, type: 0, sort: 4, url: '/onuListomci', description: 'onuListomci' },
    // oltlist 菜单
    { id: addoltId, name: 'add olt',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 1, url: '/addOlt', description: 'Add OLT' },
    { id: viewId, name: 'view',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 2, url: '/view', description: 'view' },
    { id: initId, name: 'init',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 3, url: '/init', description: 'init' },
    { id: deleteId, name: 'delete',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 4, url: '/delete', description: 'delete OLT' },
    { id: refreshId, name: 'refresh',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 5, url: '/refresh', description: 'refresh OLT' },
    { id: saveId, name: 'save',parentName:'Onulist', module_id: oltlistId, type: 2, sort: 6, url: '/save', description: 'save olt' },
    // onulist 菜单
    { id: onulistqueryId, name: 'query',parentName:'Onulist', module_id: onulistId, type: 2, sort: 1, url: '/query', description: 'query' },
    { id: onulistrefreshId, name: 'refresh',parentName:'Onulist', module_id: onulistId, type: 2, sort: 2, url: '/refresh', description: 'refresh' },
    { id: onulistdeleteonuId, name: 'delete onu',parentName:'Onulist', module_id: onulistId, type: 2, sort: 3, url: '/delete', description: 'delete onu' },
    { id: onulistbinduserId, name: 'bind',parentName:'Onulist', module_id: onulistId, type: 2, sort: 4, url: '/bind', description: 'bind' },
    // onufind 菜单
    { id: onufindqueryId, name: 'query',parentName:'Onufind', module_id: onufindId, type: 2, sort: 1, url: '/query', description: 'query' },
    { id: onufindrefreshId, name: 'refresh',parentName:'Onufind', module_id: onufindId, type: 2, sort: 2, url: '/refresh', description: 'refresh' },
    { id: onufindregistonuId, name: 'regist onu',parentName:'Onufind', module_id: onufindId, type: 2, sort: 3, url: '/regist', description: 'regist onu' },
    // tr069 菜单
    { id: searctId, name: 'regist onu',parentName:'tr069', module_id: tr069Id, type: 2, sort: 1, url: '/search', description: 'search' },
    { id: clearId, name: 'clear',parentName:'tr069', module_id: tr069Id, type: 2, sort: 2, url: '/clear', description: 'clear search condition' },
    { id: autoRefreshId, name: 'auto refresh',parentName:'tr069', module_id: tr069Id, type: 2, sort: 3, url: '/autoRefresh', description: 'auto refresh' },
    { id: createGroupId, name: 'create group',parentName:'tr069', module_id: tr069Id, type: 2, sort: 4, url: '/createGroup', description: 'create group' },
    { id: deleteGroupId, name: 'delete group',parentName:'tr069', module_id: tr069Id, type: 2, sort: 5, url: '/deleteGroup', description: 'delete group' },
    { id: moveInGroupId, name: 'move in group',parentName:'tr069', module_id: tr069Id, type: 2, sort: 6, url: '/moveInGroup', description: 'move in group' },
    { id: moveOutGroupId, name: 'move out group',parentName:'tr069', module_id: tr069Id, type: 2, sort: 7, url: '/moveOutGroup', description: 'move out group' },
    { id: sendTemplateId, name: 'send template',parentName:'tr069', module_id: tr069Id, type: 2, sort: 8, url: '/sendTemplate', description: 'send template' },
    { id: advancedId, name: 'advanced',parentName:'tr069', module_id: tr069Id, type: 2, sort: 9, url: '/advanced', description: 'advanced' },
    { id: rebootId, name: 'reboot',parentName:'tr069', module_id: tr069Id, type: 2, sort: 10, url: '/reboot', description: 'reboot' },
    { id: deleteONUId, name: 'deleteBtn',parentName:'tr069', module_id: tr069Id, type: 2, sort: 11, url: '/delete', description: 'delete onu' },
    { id: refreshONUId, name: 'refresh onu',parentName:'tr069', module_id: tr069Id, type: 2, sort: 12, url: '/refreshButton', description: 'refresh onu' },
    //account菜单
    { id: setRoleId, name: 'setRoleBtn',parentName:'Account', module_id: accountId, type: 2, sort: 1, url: '/setRoleBtn', description: 'set role' },
    { id: delRoleId, name: 'delRoleBtn',parentName:'Account', module_id: accountId, type: 2, sort: 2, url: '/delRoleBtn', description: 'delete role' },
    //userManagement菜单 
    { id:userManagement,name:'userManagement',parentName:'UserModel',module_id:user,type:0,sort:1,url:'/userManagement',description:'user management'}
  ];
  return result;
}
function getMenuNames(){
  const result = getMenus();
  const names = result.map(item=>item.name)
  return names;
}
async function addMenus(app) {
  const result = getMenus();
  await app.modelmysql.Menu.bulkCreate(result);
}
module.exports = {
  getMenus,
  addMenus,
  getMenuNames
}
